<h1>Congressos Para Avaliar:</h1>

<table cellpadding="0" cellspacing="0">
    <tr>
        <th width="40%"><?php __('Congresso'); ?></th>
        <th><?php __('Data Limite de Avaliação'); ?></th>
        <th><?php __('Total Artigos / Avaliados'); ?></th>
        <th class="actions"><?php __('Ações'); ?></th>
    </tr>
    <?php if (empty($congresses)): ?>
        <tr><td colspan="5">Você não está inscrito em nenhum congresso.</td></tr>
    <?php else: ?>
    <?php foreach ($congresses as $congress): ?>
    <?php $congress['Congress']['days_to_evaluation'] = $this->Date->diffDate(date('Y-m-d'), date('Y-m-d', strtotime($congress['Congress']['deadline_evaluation'])), 'D'); ?>
                <tr>
                    <td><?php echo $congress['Congress']['name'] ?></td>
                    <td><?php echo date('d/m/Y', strtotime($congress['Congress']['deadline_evaluation'])) . ' (' . $congress['Congress']['days_to_evaluation'] . ' dias)' ?></td>
                    <td>
            <?php
                $cnt = $cnt_av = 0;
                foreach ($congress['Article'] as $article):
                    if (!empty($article['Evaluation'])):
                        foreach ($article['Evaluation'] as $evaluation):
                            if ($evaluation['user_id'] == $userId) {
                                $cnt++;
                                if ($evaluation['status'] == 'AV')
                                    $cnt_av++;
                            }
                        endforeach;
                    endif;
                endforeach;
                echo $cnt . '/' . $cnt_av;
            ?>

            </td>
            <td class="actions">
            <?php echo $html->link(__('Ver Artigos', true), array('evaluator' => true, 'controller' => 'evaluations', 'action' => 'list', $congress['Congress']['id'])); ?>
            </td>
        </tr>
    <?php endforeach ?>
    <?php endif ?>
</table>
